<!DOCTYPE html>
<html lang="en" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
      xmlns:th="http://www.thymeleaf.org" th:fragment="header(title,keywords)">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
    <meta name="renderer" content="webkit"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-transform"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="shortcut icon" th:href="@{/user/img/bloglogo.jpg}"/>
    <link rel="apple-touch-icon" th:href="@{/user/img/apple-touch-icon.png}"/>
    <title>
        <th:block th:text="${title ?: '首页'}"></th:block>
    </title>
    <link th:href="@{/user/css/xcode.min.css}" rel="stylesheet"/>
    <link th:href="@{/user/css/style.min.css}" rel="stylesheet"/>
    <script th:src="@{/assets/js/jquery.min.js}"></script>
    <script th:src="@{/assets/js/amazeui.min.js}"></script>
    <link rel="stylesheet" th:href="@{/assets/css/amazeui.min.css}"/>
    <link rel="stylesheet" th:href="@{/assets/css/app.css}"/>
    <link th:href="@{/bootsrap/bootstrap.css}" rel="stylesheet">
    <link th:href="@{/css/mystyle.css}" rel="stylesheet">
    <script th:src="@{/jquery/jquery-1.11.3.min.js}"></script>
    <script th:src="@{/jquery/bootstrap.min.js}"></script>
    <!--[if lt IE 9]>
    <script th:src="@{/back/js/html5shiv.js}"></script>
    <script th:src="@{/back/js/respond.min.js}"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">

    <![endif]-->
</head>
<style>
</style>
<body gtools_scp_screen_capture_injected="true" th:class="${is_post}?'':'bg-
'">
<!--[if lt IE 8]>
<div class="browsehappy" role="dialog">
    当前网页 <strong>不支持</strong> 你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/" target="_blank">升级你的浏览器</a>。
</div>
<![endif]-->
<div class="layui-layout layui-layout-admin" th:fragment="topbar">
    <div class="layui-header">
        <div class="layui-logo">layui 后台布局</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left" style="margin-top: 1px;">
            <li class="layui-nav-item"><a th:href="@{/user/}">首页</a></li>
            <li class="layui-nav-item"><a href="/user/publishArticl">发布动态</a></li>
            <li class="layui-nav-item"><a th:href="@{/userArticles/}+'1/'+${session.user.getId()}">我的动态</a></li>
            <li class="layui-nav-item"><a href="/admin_users">我的疑问</a></li>
            <li class="layui-nav-item"><a href="/admin_users">我的回答</a></li>
            <li class="layui-nav-item"><a href="/admin_users">我的班级</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right" style="margin-top: 1px;">
            <li class="layui-nav-item">

                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    <span th:text="${session.user.getUsername()}"></span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="" style="background-color: #ffe2ed" data-toggle="modal"
                           data-target="#infoModal">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                    <dd><a href="/admin/logout">退出登录</a></dd>

                </dl>
        </ul>
    </div>

    <div class="navbar-container" id="search">
        <div class="navbar-search">
            <span class="icon-search"></span>
            <form role="search">
                <span class="search-box">
                    <input type="text" id="search-inp" class="input" placeholder="搜索..." maxlength="30"/>
                </span>
            </form>
        </div>
    </div>
    <script src="/layui/layui.all.js"></script>

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="infoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">模态框（Modal）标题</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" id="userForm" role="form" method="get">
                        <input type="text" name="id" th:value="${session.user.getId()}" hidden="hidden">
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">名字</label>
                            <div class="col-sm-10">
                                <input type="text" th:value="${session.user.getUsername()}" name="username"
                                       class="form-control" id="username" placeholder="请输入名字">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="password" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="text" name="password" th:value="${session.user.getPassword()}"
                                       class="form-control" id="password" placeholder="请输入密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="email" class="col-sm-2 control-label">邮箱</label>
                            <div class="col-sm-10">
                                <input type="text" name="email" th:value="${session.user.getEmail()}"
                                       class="form-control" id="email" placeholder="请输入邮箱">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="school" class="col-sm-2 control-label">学校</label>
                            <div class="col-sm-10">
                                <input type="text" name="school" th:value="${session.user.getSchool()}"
                                       class="form-control" id="school" placeholder="请输入学校名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" data-dismiss="modal" class="btn btn-default">返回</button>
                                <button type="button" class="btn btn-default" onclick="editUserInfo()">修改</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>


    <script>
        //执行修改客户操作
        function editUserInfo() {
            //alert("jahnk");
            $.post("/user/editUserInfo",
                $("#userForm").serialize(),
                function (data) {
                    if (data == "OK") {
                        alert("信息更新成功！");
                        window.location.reload();
                    } else {
                        alert("信息更新失败！");
                        window.location.reload();
                    }
                }
            )
        }
    </script>

</div>
</body>
</html>